#include <bits/stdc++.h>
#define re register
#define int long long
#define Mul(a,b) ((a) * (b) % mod)
#define Div(a,b) (Mul(a,qmi(b,mod - 2)))
#define chMul(a,b) (a = Mul(a,b))

using namespace std;

const int N = 2010;
const int mod = 998244353;
int n;
int x[N],r[N],g[N];

inline int read(){
    int r = 0,w = 1;
    char c = getchar();
    while (c < '0' || c > '9'){
        if (c == '-') w = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9'){
        r = (r << 3) + (r << 1) + (c ^ 48);
        c = getchar();
    }
    return r * w;
}

inline int gcd(int a,int b){
    if (!b) return a;
    else return gcd(b,a % b);
}

inline int qmi(int a,int b){
    int res = 1;
    while (b){
        if (b & 1) chMul(res,a);
        chMul(a,a); b >>= 1;
    } return res;
}

namespace Sub1{
    int L,ans[N];

    inline bool check(){
        L = r[1] + g[1];
        for (re int i = 2;i <= n;i++){
            int t = r[i] + g[i];
            L = L / gcd(t,L) * t;
            if (L > 1e3) return false;
        } return true;
    }

    inline void solve(){
        int tot = L;
        for (re int i = 0;i < L;i++){
            for (re int j = 1;j <= n;j++){
                if ((i + x[j]) % (r[j] + g[j]) < r[j]){
                    tot--; ans[j]++; break;
                }
            }
        } ans[n + 1] = tot;
        int inv = qmi(L,mod - 2);
        for (re int i = 1;i <= n + 1;i++) printf("%lld\n",Mul(ans[i],inv));
    }
}

signed main(){
    freopen("traffic.in","r",stdin);
    freopen("traffic.out","w",stdout);
    n = read();
    for (re int i = 1;i <= n;i++) x[i] = read(),r[i] = read(),g[i] = read();
    if (Sub1::check()) Sub1::solve();
    return 0;
}